<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>代理用户列表</h2>
	</div>
	<div class="cf">
		<div class="fl">
            <button class="btn ajax-post confirm" url="{:U('User/changeAngentStatus',array('method'=>'deleteUser'))}" target-form="ids">删 除</button>
        </div>

        <!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<input type="text" name="username" class="search-input" value="{:I('username')}" placeholder="请输入用户昵称或者ID">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('agent')}"><i class="btn-search"></i></a>
			</div>

			<div class="btn-group-click adv-sch-pannel fl">
				<button class="btn">高 级 搜 索<i class="btn-arrowdown"></i></button>
				<div class="dropdown cf">
					<div class="row">
						<a href="{:U('agent')}" id="all">全部</a>
						<a href="{:U('agent',array('status'=>'1'))}" id="agent">通过审核</a>
						<a href="{:U('agent',array('status'=>'2'))}" id="department">未通过审核</a>
						<a href="{:U('agent',array('status'=>'0'))}" id="major">正在审核</a>
					</div>
				</div>
			</div>
		</div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class="">UID</th>
		<th class="">用户名</th>
		<th class="">真实姓名</th>
		<th class="">电话</th>
		<th class="">注册时间</th>
		<th class="">所属部门</th>
		<th class="">状态</th>
		<if condition="is_administrator()">
			<th class="">操作</th>
		</if>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
			<td>{$vo.uid} </td>
			<td>{$vo.username}</td>
			<td>{$vo.nickname}</td>
			<td>{$vo.mobile}</td>
			<td>{$vo.reg_time|time_format}</td>
			<td>{$vo.department|get_department_name}</td>
			<td>
				<switch name="vo.status">
					<case value="0">正在审核</case>
					<case value="1">审核通过</case>
					<case value="2">审核未通过</case>
				</switch>
			</td>
			<if condition="is_administrator()">
			<td>
				<eq name="vo.status" value="0">
				  <a href="{:U('User/changeAngentStatus?method=resumeUser&id='.$vo['uid'])}" class="ajax-get">通过审核</a>
				  <a href="{:U('User/changeAngentStatus?method=forbidUser&id='.$vo['uid'])}" class="ajax-get">拒绝通过</a>
				</eq>
				<a href="{:U('User/editAgent?uid='.$vo['uid'])}">编辑</a>
			 	<a href="{:U('User/changeAngentStatus?method=deleteUser&id='.$vo['uid'])}" class="confirm ajax-get">删除</a>
            </td>
			</if>
		</tr>
		</volist>
		<else/>
		<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    highlight_subnav('{:U("User/agent")}');
	</script>
</block>
